package src.data;

import java.util.Set;
import src.domain.MailBox;
import src.domain.PostOffice;

public class PostOfficeSRV {

	private static PostOfficeDAO dao;
	static {
		dao = PostOfficeDAO.getInstance();
	}
	
	public static PostOffice getByID(long idPostOffice){
		PostOffice postOffice=new PostOffice();
		postOffice.setId(idPostOffice);
		return dao.getByID(postOffice);
	}
	
	public static PostOffice getByName(String namePostOffice){
		PostOffice postOffice=new PostOffice();
		postOffice.setName(namePostOffice);
		return dao.getByName(postOffice);
	}
	
	public static void save(String name, Set<MailBox> mailBoxes,Set<PostOffice> trustOffices){
		PostOffice postOffice = new PostOffice();
		postOffice.setName(name);

		//postOffice.setMailBoxes(mailBoxes);
		postOffice.setTrustOffices(trustOffices);
		dao.save(postOffice);	
	}
	
	public static void update(PostOffice postOffice){
			dao.update(postOffice);
	}
	
	public static void delete(long idPostOffice){
		dao.delete(getByID(idPostOffice));
	}
	
	public static Set<PostOffice> getAll(){
		return dao.getAll();
	}
	
	public static Set<PostOffice> getPostOffices(String name){
		PostOffice postOffice=new PostOffice();
		postOffice.setName(name);
		return dao.getPostOffices(postOffice);
	}
	
	public static Set<PostOffice> getAvailablePostOffices(PostOffice postOffice) {
		return dao.getAvailablePostOffices(postOffice);
	}
	

}

